def judge(s: str):
    if s == '0':
        return True
    if s[0] == '0':
        return False
    return 0 < int(s) <= 255

def pick(s: list[str], r: list[str]):
    if len(s) == 4:
        if judge(s[3]):
            r.append(s[0] + '.' + s[1] + '.' + s[2] + '.' + s[3])
        return
    last = s.pop()
    for i in range(1, min(3, len(last)-1) + 1):
        a, b = last[:i], last[i:]
        if judge(a):
            pick(s + [a, b], r)

def func(s: str)->list[str]:
    ret = []
    pick([s], ret)
    return ret

test = [
    '25525511135',
    '0000',
    '101023',
    '123451078',
    '11111111',
    '123',
    '888888',
]

if __name__ == '__main__':
    for x in test:
        print('Test case:')
        print('Input:', x)
        print('Output:', func(x))
